# Contributor: Christoph Reiter <reiter.christoph@gmail.com>

_realname=pluggy
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.6.0
pkgrel=1
pkgdesc='Plugin and hook calling mechanisms for python (mingw-w64)'
url='https://github.com/pytest-dev/pluggy'
license=('MIT')
arch=('any')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python3"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('7f8ae7f5bdf75671a718d2daf0a64b7885f74510bcd98b1a0bb420eb9a9d0cff')

prepare() {
  cd ${srcdir}

  for pver in {2,3}; do
    rm -rf python${pver}-build-${CARCH}| true
    cp -r "${_realname}-${pkgver}" "python${pver}-build-${CARCH}"
  done
}

package_python3-pluggy() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd ${srcdir}/python3-build-${CARCH}
  ${MINGW_PREFIX}/bin/python3 setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-pluggy() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd ${srcdir}/python2-build-${CARCH}
  ${MINGW_PREFIX}/bin/python2 setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-pluggy() {
  package_python2-pluggy
}

package_mingw-w64-i686-python3-pluggy() {
  package_python3-pluggy
}

package_mingw-w64-x86_64-python2-pluggy() {
  package_python2-pluggy
}

package_mingw-w64-x86_64-python3-pluggy() {
  package_python3-pluggy
}
